package run.core;

import java.util.ArrayList;
import java.util.List;

import run.Cell;
import run.Facet;

/**
	SOUT takes in an ArrayList of objects and prints them out onto standard output as comma-separated 
	strings.
		<(.data) SOUT>
		data: a list of INT, FLT, BOOL, or STR
	@author Greg Bramble
*/

public class SOUT extends Cell {
	Facet data;
	
	public SOUT(String labelName){
		super("SOUT", labelName);
		data = new Facet(".data", this, INPUT_FACET);
	}
	
	//converts the value of the facet to an ArrayList of objects and prints each one separated by a comma
	@Override
	public List<Facet> stimulate(Facet stimmer) {
		List<Object> datums = data.dispatchOutbound();
		for (Object o : datums)
			if (!(o instanceof NIL))
				System.out.println(o);
		
		System.out.println("");
		return new ArrayList<Facet>();
	}
	
	public List<Facet> getFacets()
	{
		ArrayList<Facet> temp = new ArrayList<Facet>();
		temp.add(data);
		return temp;
	}	
	
	//Dot printout method
	public String toDot(String prefix)
	{
		String returnString = "";
		returnString += "subgraph " + "cluster_" + cellTypeName + hashCode() + "{\n";
		returnString += "label = \"" + cellTypeName + "\";\n";
		
		//Print my facets
		returnString += prefix + cellTypeName + hashCode() + "data [label=\".data\"];\n";
		
		returnString += "}\n";
		return returnString;
	}	
}